package com.github.itdachen.constants;

/**
 * 数据库字段
 *
 * @author 王大宸
 * @date 2025/3/10 21:48
 */
public enum FieldAttrEnum {

    LONG {
        @Override
        public String javaType() {
            return JavaFieldConstants.LONG;
        }

        @Override
        public HtmlTypeEnum htmlType() {
            return HtmlTypeEnum.INPUT;
        }

        @Override
        public String[] attr() {
            return new String[]{"bigint", "tinyint"};
        }


    },

    STRING {
        @Override
        public String javaType() {
            return JavaFieldConstants.STRING;
        }

        @Override
        public HtmlTypeEnum htmlType() {
            return HtmlTypeEnum.INPUT;
        }

        @Override
        public String[] attr() {
            return new String[0];
        }

    },

    INTEGER {
        @Override
        public String javaType() {
            return JavaFieldConstants.INTEGER;
        }

        @Override
        public HtmlTypeEnum htmlType() {
            return HtmlTypeEnum.INPUT;
        }

        @Override
        public String[] attr() {
            return new String[]{"int", "tinyint", "smallint", "mediumint", "integer", "number", "NUMBER"};
        }


    },

    DOUBLE {
        @Override
        public String javaType() {
            return JavaFieldConstants.DOUBLE;
        }

        @Override
        public HtmlTypeEnum htmlType() {
            return HtmlTypeEnum.INPUT;
        }

        @Override
        public String[] attr() {
            return new String[]{"double"};
        }
    },

    FLOAT {
        @Override
        public String javaType() {
            return JavaFieldConstants.FLOAT;
        }

        @Override
        public HtmlTypeEnum htmlType() {
            return HtmlTypeEnum.INPUT;
        }

        @Override
        public String[] attr() {
            return new String[]{"float"};
        }
    },

    BIG_DECIMAL {
        @Override
        public String javaType() {
            return JavaFieldConstants.BIG_DECIMAL;
        }

        @Override
        public HtmlTypeEnum htmlType() {
            return HtmlTypeEnum.INPUT;
        }

        @Override
        public String[] attr() {
            return new String[]{"decimal"};
        }
    },

    BOOLEAN {
        @Override
        public String javaType() {
            return JavaFieldConstants.BOOLEAN;
        }

        @Override
        public HtmlTypeEnum htmlType() {
            return HtmlTypeEnum.INPUT;
        }

        @Override
        public String[] attr() {
            return new String[]{"bit"};
        }
    },

    TEXT_AREA {
        @Override
        public String javaType() {
            return JavaFieldConstants.STRING;
        }

        @Override
        public HtmlTypeEnum htmlType() {
            return HtmlTypeEnum.TEXT_AREA;
        }

        @Override
        public String[] attr() {
            return new String[]{"tinytext", "text", "mediumtext", "longtext", "blob", "longtext", "text", "remarks", "remark", "describe", "des", "desc",
                    "describes", "REMARKS", "REMARK", "descriptions", "description", "DESCRIPTIONS", "DESCRIPTION"};
        }
    },

    LOCAL_DATE_TIME {
        @Override
        public String javaType() {
            return JavaFieldConstants.LOCAL_DATE_TIME;
        }

        @Override
        public HtmlTypeEnum htmlType() {
            return HtmlTypeEnum.LOCAL_DATE_TIME;
        }

        @Override
        public String[] attr() {
            return new String[]{"datetime", "update_time", "create_time", "updateTime", "createTime", "time", "date", "DATE", "timestamp"};
        }
    },


    ;

    /**
     * java 类型, 例如: String, Long, Integer 等
     */
    public abstract String javaType();

    /**
     * 表单展示形式, 例如: input, textarea, select, radio 等
     */
    public abstract HtmlTypeEnum htmlType();

    /**
     * 属性, java 字段, 数据库属性等
     */
    public abstract String[] attr();


}
